package com.bcx.service;

import com.bcx.mapper.HouseinfoMapper;
import com.bcx.pojo.Houseinfo;
import com.bcx.pojo.HouseinfoExample;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HouseinfoServiceImpl implements HouseinfoService {
    @Resource
    HouseinfoMapper houseinfoMapper;
    @Override
    public PageInfo<Houseinfo> selectAll(Integer pageNum) {
        PageHelper.startPage(pageNum,2);
        HouseinfoExample example=new HouseinfoExample();
        HouseinfoExample.Criteria criteria=example.createCriteria();
        List<Houseinfo> houseinfos=houseinfoMapper.selectByExample(example);
        PageInfo<Houseinfo> pageInfo=new PageInfo<>(houseinfos);
        return pageInfo;
    }

    @Override
    public int add(Houseinfo houseinfo) {
        return houseinfoMapper.insert(houseinfo);
    }
}
